"use strict";
// socket.io
const http = require("http");
const server = http.createServer();
const io = require("socket.io")(server);
exports.main = async (event, context) => {
  //event为客户端上传的参数
  console.log("event : ", event);
  io.on("connection", (socket) => {
    console.log("a user connected");
    socket.on("chat message", (msg) => {
      console.log("message: " + msg);
      io.emit("chat message", msg);
    });
    socket.on("disconnect", () => {
      console.log("user disconnected");
    });
  });
  console.log(openai_res);
  //返回数据给客户端
  return event;
};
